package com.zhiche.lisa.mdm.controller.outer;

import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import com.zhiche.lisa.mdm.dao.model.DrivingLicenseType;
import com.zhiche.lisa.mdm.service.DrivingLicenseTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/driverLicenType")
@Api(value = "/driverLicenType", description = "驾照类型接口",tags={"驾照类型接口"})
public class OutDrivingLicenseTypeController {

    private static final Logger LOGGER = LoggerFactory.getLogger(OutDrivingLicenseTypeController.class);

    @Autowired
    private DrivingLicenseTypeService drivingLicenseTypeService;


    /**
     * 获取所有的准驾车型
     * @return
     */
    @GetMapping(value = "/getAllDrivingType")
    @ApiOperation(value = "获取所有的准驾车型", notes = "获取所有的准驾车型", produces = MediaType.APPLICATION_JSON_VALUE,response = RestfulResponse.class)
    public RestfulResponse<List<DrivingLicenseType>> getAllDrivingType(){
        LOGGER.info("获取所有的准驾车型");
        RestfulResponse result = new RestfulResponse<>(0,"success",null);

        try {
            List<DrivingLicenseType> list = drivingLicenseTypeService.getAllDrivingType();
            result.setData(list);
        } catch (BaseException e) {
            LOGGER.error("DriverController.getAllDrivingType ERROR... ", e);
            result = new RestfulResponse<>(-1, e.getMessage(), null);
        }

        return result;
    }

}
